import request from '@/config/axios'

// 反馈数据结构
export interface FeedbackVO {
  id?: number
  userId?: number
  userName?: string
  feedbackType?: string
  content?: string
  contactInfo?: string
  status?: number
  remark?: string
  handleTime?: string
  createTime?: string
  updateTime?: string
}

// 反馈统计数据结构
export interface FeedbackStatsVO {
  totalFeedbacks: number
  pendingFeedbacks: number
  handledFeedbacks: number
  todayNewFeedbacks: number
  typeStats: {
    bug: number
    suggestion: number
    complaint: number
    other: number
  }
}

// 查询反馈列表
export const getFeedbackPage = (params: {
  current?: number
  size?: number
  keyword?: string
  type?: string
  status?: number
}) => {
  return request.get({ url: '/api/admin/feedbacks', params })
}

// 获取反馈详情
export const getFeedback = (id: number) => {
  return request.get({ url: `/api/admin/feedbacks/${id}` })
}

// 处理反馈
export const handleFeedback = (id: number, params: {
  status: number
  handleResult?: string
}) => {
  return request.put({ url: `/api/admin/feedbacks/${id}/handle`, params })
}

// 删除反馈
export const deleteFeedback = (id: number) => {
  return request.delete({ url: `/api/admin/feedbacks/${id}` })
}

// 获取反馈统计数据
export const getFeedbackStats = () => {
  return request.get({ url: '/api/admin/feedbacks/stats' })
}

// 批量处理反馈
export const batchHandleFeedbacks = (params: {
  ids: string
  status: number
  handleResult?: string
}) => {
  return request.put({ url: '/api/admin/feedbacks/batch-handle', params })
}